<template>
	<view class="page">
		<view class="head-back">
			<view class="back" @click="onBack">
				<text></text>
			</view>
			<view class="title">
				<image src="/static/flash_title.png" mode=""></image>
			</view>
		</view>
		<view class="head-bg">
			<view class="session" :class="{'activity':scrollTop > 50}">
				<view class="list action" @click="onTime('16:00')">
					<text class="time">16:00</text>
					<text class="status">抢购中</text>
				</view>
				<view class="list" @click="onTime('18:00')">
					<text class="time" >18:00</text>
					<text class="status">即将开始</text>
				</view>
				<view class="list"  @click="onTime('20:00')">
					<text class="time">20:00</text>
					<text class="status">即将开始</text>
				</view>
				<view class="list" @click="onTime('22:00')">
					<text class="time" >22:00</text>
					<text class="status">即将开始</text>
				</view>
				<view class="list" @click="onTime('00:00')">
					<text class="time" >00:00</text>
					<text class="status">即将开始</text>
				</view>
			</view>
		</view>
		<view class="goods-list">
			<view class="list" v-for="(item,index) in seckillList" 
			
			:key="index" >
				<view class="thumb" v-for="(value,key) in item.seckillList">
					<image :src="value.images"></image>
				</view>
				<view class="item" v-for="(value,key) in item.seckillList">
					<view class="title">
						<text class="one-omit">{{value.title}}</text>
					</view>
					<view class="price-data">
						<view class="price">
							<text>￥{{value.price}}</text>
							<text class="lineation ">￥{{value.ot_price}}</text>
						</view>
						<view class="data">
							<view class="btn" @click="onGoods(value.goods_id,item.id,value.id)">
								<text>立即抢购</text>
							</view>
							<view class="schedule">
								<view class="num">已售50%</view>
								<view class="bar">
									<text></text>
								</view>
							</view>
						</view>
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scrollTop: 0,
				seckillList:[]
			};
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		methods:{
			/**
			 * 返回
			 */
			onBack(){
				uni.navigateBack();
			},
			/**
			 * 商品点击
			 */
			onGoods(id,config_id,seckill_id,){
				console.log(seckill_id)
				this.$http.get('seckill/init',{
					seckill_id:seckill_id
				},{}).then(res => {
					console.log(res)
					uni.navigateTo({
						url: '/pages/FlashGoodsDetails/FlashGoodsDetails?goods_id=' + id+ "&seckill_id="+config_id+"&type="+1
					})
				})
			},
			
			onTime(time){
				uni.showLoading({title: '加载中',mask:true});
				this.$http.get('seckillList', {
					time:time
				},{}).then(res => {
					console.log(res.data.data)
					
					if(res.data.data.length >0){
						this.seckillList = res.data.data
						setTimeout(function () {uni.hideLoading();}, 100);
					}else{
						setTimeout(function () {uni.hideLoading();}, 100);
						this.seckillList = res.data.data
						uni.showToast({
						    title: "没有您要找的数据",
						    duration: 2000,
							icon:"none"
						});
					}
				})
			}
		},
		onLoad() {
			var timestamp = Date.parse(new Date()) / 1000;
			// console.log(timestamp)
		},
		onReady() {
			var time = "16:00"
			// console.log(timestamp)
			this.$http.get('seckillList', {
				time:time
			},{}).then(res => {
				console.log(res.data.data)
				this.seckillList = res.data.data
			})
		}
	}
</script>

<style scoped lang="scss">
	@import 'FlashSale.scss';
</style>
